﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Blog.Models;

namespace Blog.Controllers
{
    public class CommentController : Controller
    {
        public string EmbeddedViewPath
        {
            get
            {
                return string.Format("~/Plugins/Blog.dll/Blog.Views.{0}.{1}.aspx",
                     this.ControllerContext.RouteData.Values["controller"],
                      this.ControllerContext.RouteData.Values["action"]);
            }
        }

        public ActionResult Create()
        {
            return View(this.EmbeddedViewPath);
        }

        [HttpPost]
        public ActionResult Create(Comment commentToCreate)
        {
            Context.Instance.CreateComment(commentToCreate.PostId, commentToCreate);
            return RedirectToAction("View", "Post", new { Id = commentToCreate.PostId });
        }
    }
}
